package llama.core;

import java.beans.PropertyChangeListener;

import llama.network.NetworkMessage;
import llama.util.SystemMessage;

/**
 * This interface defines the client-application model.
 */
public interface IChatModel extends PropertyChangeListener {

	/**
	 * Sets the provided IUser as the active user of this object.
	 * @param activeUser the IUser to be set as active user. 
	 */
	void setActiveUser(IUser activeUser);

	/**
	 * Gets the active user of this object.
	 * @return the IUser set as the active user.
	 */
	IUser getActiveUser();

	/**
	 * Sets the provided ContactList as the contact list of this object.
	 * @param contactList the ContactList that should be set as contact list.
	 */
	void setContactList(ContactList contactList);

	/**
	 * Gets the contact list of this object.
	 * @return the ContactList stored in this object.
	 */
	ContactList getContactList();

	/**
	 * Connects this object to it's network sub-system.
	 * @param nm the network message that should be sent upon connection.
	 */
	void connect(NetworkMessage nm);
	
	/**
	 * Severs connection to this objects network sub-system.
	 */
	void logout();
	
	/**
	 * Returns true if this object has been fully initialized otherwise false is returned.
	 * @return true if this object has been fully initialized. 
	 */
	boolean isReady();
	
	/**
	 * Adds a PropertyChangeListener to this object. 
	 * @param pcl the PropertyChangeListener to be added.
	 */
	void addPropertyChangeListener(PropertyChangeListener pcl);

	/**
	 * Removes a PropertyChangeListener to this object.
	 * @param pcl the PropertyChangeListener to be removed.
	 */
	void removePropertyChangeListener(PropertyChangeListener pcl);

	/**
	 * Sends a NetworkMessage through this objects network sub-system.
	 * @param networkMessage the message that should be sent.
	 */
	void send(NetworkMessage networkMessage);

	/**
	 * Sends a SystemMessage to this objects listeners.
	 * @param systemMessage the message that should be sent.
	 */
	void send(SystemMessage systemMessage);

	/**
	 * Loads the login settings of this object.
	 */
	void loadLoginSettings();

	/**
	 * Stores the login settings of this object.
	 * @param settings
	 */
	void saveLoginSettings(LoginSettings settings);

	/**
	 * Sets the host-address of this objects network sub-system.
	 * @param host
	 */
	void editHost(String host);

}
